﻿
namespace HSS.Xaml.UI.Interactivity
{
	#region RectangleDoubleClickTrigger
	/// <summary>
	/// DoubleClickTrigger for a Rectangle.
	/// </summary>
	public class RectangleDoubleClickTrigger : DoubleClickTrigger<System.Windows.Shapes.Rectangle>
	{
		#region Constructors
		/// <summary>
		/// Constructor
		/// </summary>
		public RectangleDoubleClickTrigger()
		{
		}
		#endregion

		#region Overrides
		/// <summary>
		/// Connect to the AssociatedObject events that will trigger the DoubleClick.
		/// </summary>
		protected override void ConnectEvent()
		{
			this.AssociatedObject.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(AssociatedObject_MouseLeftButtonDown);
		}
		/// <summary>
		/// Disconnect from the AssociatedObject events that will trigger the DoubleClick.
		/// </summary>
		protected override void DisconnectEvent()
		{
			this.AssociatedObject.MouseLeftButtonDown -= new System.Windows.Input.MouseButtonEventHandler(AssociatedObject_MouseLeftButtonDown);
		}
		#endregion

		#region Event Handlers
		void AssociatedObject_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
		{
			if (base.DoubleClickDetection.ProcessClick(sender))
				base.OnDoubleClick();
		}
		#endregion
	}
	#endregion
}